App({
  onLaunch: function() {
    // 处理金币
    var gold = wx.getStorageSync('baibao_userinfo_gold');
    if (gold) {
      this.globalData.gold = gold
    } else {
      gold = 0
    }
    wx.setStorageSync('baibao_userinfo_gold', gold)

    // 处理历史记录
    var list = wx.getStorageSync('baibao_game_history')
    if (!list) {
      wx.setStorageSync('baibao_game_history', [])
    }

    // 处理每日任务
    var now = new Date()
    var today = now.getFullYear() + '-' + (now.getMonth() + 1) + '-' + now.getDate()
    var yesterday = now.getFullYear() + '-' + (now.getMonth() + 1) + '-' + (now.getDate() - 1)
    var taskList = wx.getStorageSync('baibao_task_list_' + today)
    if (!taskList) {
      taskList = {
        'sign': 0,
        'one_game': 0,
        'share': 0,
        'five_game': 0
      }
    }
    wx.removeStorageSync('baibao_task_list_' + yesterday)
    wx.setStorageSync('baibao_task_list_' + today, taskList)
    this.globalData.taskList = taskList
  },

  globalData: {
    gold: 0,
    version: '1.2.1',
    taskList: [],
    url: 'https://xcx.nanxuncn.cn/api/hezi/baibao/',
  }
})